home *** CD-ROM | disk | FTP | other *** search
-
- // Copyright (C) 2002 by Luigi Pino. All Rights Reserved.
-
- /***************************************************************************/
-
- #include "../library/neurosis.h"
- #include "draw.h"
- #include "file_io.h"
- #include "hiscore.h"
- #include "initialize.h"
- #include "main.h"
- #include "menu_misc.h"
- #include "paddle.h"
- #include "sphere.h"
- #include "update.h"
-
- /***************************************************************************/
-
- Controller_Class input;
-
- extern Camera_Class camera;
- extern Mouse_Class mouse;
- extern Object3_Class ground_cover;
- extern Object4_Class ground;
- extern Object4_Class wall_net;
- extern Object4_Class wall_side;
- extern Paddle_Struct paddle_object[];
- extern Shadow_Box_Struct light_source;
- extern Values_Struct values;
- extern Sub_Menu_Class menu_options;
- extern Window_Class window;
-
- extern bool connected[];
- extern float3 wall_pts[];
- extern int goal_by_team;
-
- /***************************************************************************/
-
- void Initialize_Game()
-
- {
- input.Clear();
- mouse.Clear();
-
- for (int x1=0;x1<values.sphere_number;x1=x1+1)
- Initialize_Sphere_Object(x1);
-
- goal_by_team = -1;
-
- Initialize_Paddle_Object();
- Initialize_Wall_Points(40.0f, 200.0f, 300.0f);
-
- camera.axis_current.x = camera.axis_destination.x = 320.0f;
- camera.axis_current.z = camera.axis_destination.z = 0.0f;
- camera.axis_speed = 30.0f;
- camera.zoom_current = camera.zoom_destination = -500.0f;
- camera.zoom_speed = 100.0f;
-
- values.fade_amount = 0.0f;
- values.game_end_fade = false;
- values.game_start_fade = true;
- values.paddle_speed = 65.0f;
- values.wall_height = 50.0f;
-
- // Change sound to current menu choice
- if (menu_options.Get_Current_Choice(0) == 0)
- values.sound = true;
- else
- values.sound = false;
-
- if (paddle_object[Up].input.user == No_User)
- {
- wall_pts[35].x = -20.0f;
- wall_pts[36].x = 20.0f;
- wall_pts[35].y = wall_pts[36].y = 185.0f;
- }
-
- if (paddle_object[Down].input.user == No_User)
- {
- wall_pts[12].x = -20.0f;
- wall_pts[11].x = 20.0f;
- wall_pts[11].y = wall_pts[12].y = -185.0f;
- }
-
- if (paddle_object[Left].input.user == No_User)
- {
- wall_pts[23].x = wall_pts[24].x = -185.0f;
- wall_pts[23].y = -20.0f;
- wall_pts[24].y = 20.0f;
- }
-
- if (paddle_object[Right].input.user == No_User)
- {
- wall_pts[47].x = wall_pts[48].x = 185.0f;
- wall_pts[48].y = -20.0f;
- wall_pts[47].y = 20.0f;
- }
-
- Initialize_Ground();
- Initialize_Ground_Cover();
- Initialize_Wall();
- }
-
- /***************************************************************************/
-
- void Initialize_Ground()
-
- {
- int x1;
- int y1;
-
- ground.Set_Texture_Image(t_inside_ground);
-
- for (x1=0;x1<10;x1=x1+1)
- for (y1=0;y1<10;y1=y1+1)
- {
- ground.Set_Position(y1 + (x1 * 10), -190.0f + ((float)(x1) * 38.0f), -190.0f + ((float)(y1 + 1) * 38.0f), 0.0f,
- -190.0f + ((float)(x1 + 1) * 38.0f), -190.0f + ((float)(y1 + 1) * 38.0f), 0.0f,
- -190.0f + ((float)(x1 + 1) * 38.0f), -190.0f + ((float)(y1) * 38.0f), 0.0f, -190.0f + ((float)(x1) * 38),
- -190.0f + ((float)(y1) * 38.0f), 0.0f);
- }
- }
-
- /***************************************************************************/
-
- void Initialize_Ground_Cover()
-
- {
- color3 color = {0.0f, 0.0f, 0.0f};
- float3 top_left = {-200.0f, 200.0f, 1.0f};
- float3 top_right = {200.0f, 200.0f, 1.0f};
- float3 bottom_right = {200.0f, -200.0f, 1.0f};
- float3 bottom_left = {-200.0f, -200.0f, 1.0f};
- int x1;
-
- // Top Left
- for (x1=0;x1<11;x1=x1+1)
- {
- ground_cover.Set_Color(x1, &color, &color, &color);
- ground_cover.Set_Position(x1, &top_left, &wall_pts[24 + x1], &wall_pts[25 + x1]);
- }
-
- // Top Right
- for (x1=0;x1<11;x1=x1+1)
- {
- ground_cover.Set_Color(11 + x1, &color, &color, &color);
- ground_cover.Set_Position(11 + x1, &top_right, &wall_pts[36 + x1], &wall_pts[37 + x1]);
- }
-
- // Bottom Right
- ground_cover.Set_Color(22, &color, &color, &color);
- ground_cover.Set_Position(22, &bottom_right, &wall_pts[48], &wall_pts[49]);
-
- for (x1=0;x1<10;x1=x1+1)
- {
- ground_cover.Set_Color(23 + x1, &color, &color, &color);
- ground_cover.Set_Position(23 + x1, &bottom_right, &wall_pts[1 + x1], &wall_pts[2 + x1]);
- }
-
- // Bottom Left
- for (x1=0;x1<11;x1=x1+1)
- {
- ground_cover.Set_Color(33 + x1, &color, &color, &color);
- ground_cover.Set_Position(33 + x1, &bottom_left, &wall_pts[12 + x1], &wall_pts[13 + x1]);
- }
-
- // Top net cover
- ground_cover.Set_Color(44, &color, &color, &color);
- ground_cover.Set_Position(44, &top_left, &top_right, &wall_pts[35]);
- ground_cover.Set_Color(45, &color, &color, &color);
- ground_cover.Set_Position(45, &top_right, &wall_pts[35], &wall_pts[36]);
-
- // Right net cover
- ground_cover.Set_Color(46, &color, &color, &color);
- ground_cover.Set_Position(46, &top_right, &bottom_right, &wall_pts[47]);
- ground_cover.Set_Color(47, &color, &color, &color);
- ground_cover.Set_Position(47, &bottom_right, &wall_pts[47], &wall_pts[48]);
-
- // Bottom net cover
- ground_cover.Set_Color(48, &color, &color, &color);
- ground_cover.Set_Position(48, &bottom_right, &bottom_left, &wall_pts[11]);
- ground_cover.Set_Color(49, &color, &color, &color);
- ground_cover.Set_Position(49, &bottom_left, &wall_pts[11], &wall_pts[12]);
-
- // Right net cover
- ground_cover.Set_Color(50, &color, &color, &color);
- ground_cover.Set_Position(50, &bottom_left, &top_left, &wall_pts[23]);
- ground_cover.Set_Color(51, &color, &color, &color);
- ground_cover.Set_Position(51, &top_left, &wall_pts[23], &wall_pts[24]);
- }
-
- /***************************************************************************/
-
- bool Initialize_Objects()
-
- {
- bool okay[4];
-
- okay[0] = ground.Set_Size(100);
- okay[1] = ground_cover.Set_Size(52);
- okay[2] = wall_net.Set_Size(4);
- okay[3] = wall_side.Set_Size(44);
-
- for (int x1=0;x1<4;x1=x1+1)
- {
- if (okay[x1] == false)
- return (false);
- }
-
- return (true);
- }
-
- /***************************************************************************/
-
- void Initialize_System()
-
- {
- light_source.color.r = 1.0f;
- light_source.color.g = 1.0f;
- light_source.color.b = 1.0f;
- light_source.brightness = 2.6f;
- light_source.range = 300.0f;
- light_source.position.z = 180.0f;
- values.game_position = Game_Intro;
- values.intro_count = 0.0f;
-
- srand((unsigned)time(NULL));
- window.zNear = 20.0f;
- window.zFar = 6000.0f;
-
- connected[Keyboard_1] = true;
- connected[Keyboard_2] = true;
- connected[Computer] = true;
- connected[No_User] = true;
-
- // 0 - OK
- // 165 - Not hooked up
- // 167 - Unplugged
- JOYINFOEX joystick_check;
- joystick_check.dwSize = sizeof(JOYINFOEX);
-
- for (int x1=Joystick_1;x1<=Joystick_4;x1=x1+1)
- {
- if (joyGetPosEx(x1 - Joystick_1, &joystick_check) == 0)
- connected[x1] = true;
- else
- connected[x1] = false;
- }
- }
-
- /***************************************************************************/
-
- void Initialize_Textures(bool change_resolution)
-
- {
- if (change_resolution == false)
- {
- window.Load_Texture(t_menu_1, "Data/intro_1.bmp");
- window.Load_Texture(t_menu_2, "Data/intro_2.bmp");
- }
- else
- {
- window.Load_Texture(t_menu_1, "Data/menu_1.bmp");
- window.Load_Texture(t_menu_2, "Data/menu_2.bmp");
- }
-
- window.Load_Texture(t_font, "Data/font.bmp");
- window.Load_Texture(t_font_mask, "Data/font_mask.bmp");
- window.Load_Texture(t_menu_3, "Data/intro_3.bmp");
- window.Load_Texture(t_menu_mask_1, "Data/menu_mask_1.bmp");
- window.Load_Texture(t_menu_mask_2, "Data/menu_mask_2.bmp");
- window.Load_Texture(t_inside_ground, "Data/inside_ground.bmp");
- window.Load_Texture(t_side_wall, "Data/side_wall.bmp");
- window.Load_Texture(t_net_wall, "Data/net_wall.bmp");
- window.Load_Texture(t_paddle, "Data/paddle.bmp");
- window.Load_Texture(t_arrow, "Data/arrow.bmp");
- window.Load_Texture(t_sphere, "Data/sphere.bmp");
- }
-
- /***************************************************************************/
-
- void Initialize_Wall()
-
- {
- int x1;
-
- wall_net.Set_Texture_Image(t_net_wall);
- wall_side.Set_Texture_Image(t_side_wall);
-
- // Bottom Right Corner
- for (x1=0;x1<9;x1=x1+1)
- {
- wall_side.Set_Texture_Position(x1, 0.111f * x1, 1.0f, (1 + x1) * 0.111f, 1.0f, (1 + x1) * 0.111f, 0.0f, 0.111f * x1, 0.0f);
- wall_side.Set_Position(x1, wall_pts[1 + x1].x, wall_pts[1 + x1].y, values.wall_height, wall_pts[2 + x1].x,
- wall_pts[2 + x1].y, values.wall_height, wall_pts[2 + x1].x, wall_pts[2 + x1].y, 0.0f, wall_pts[1 + x1].x,
- wall_pts[1 + x1].y, 0.0f);
- }
-
- // Bottom Wall
- wall_side.Set_Position(9, wall_pts[10].x, wall_pts[10].y, values.wall_height, wall_pts[11].x, wall_pts[11].y,
- values.wall_height, wall_pts[11].x, wall_pts[11].y, 0.0f, wall_pts[10].x, wall_pts[10].y, 0.0f);
-
- wall_net.Set_Position(0, wall_pts[11].x, wall_pts[11].y, values.wall_height, wall_pts[12].x, wall_pts[12].y,
- values.wall_height, wall_pts[12].x, wall_pts[12].y, 0.0f, wall_pts[11].x, wall_pts[11].y, 0.0f);
-
- wall_side.Set_Position(10, wall_pts[12].x, wall_pts[12].y, values.wall_height, wall_pts[13].x, wall_pts[13].y,
- values.wall_height, wall_pts[13].x, wall_pts[13].y, 0.0f, wall_pts[12].x, wall_pts[12].y, 0.0f);
-
- // Bottom Left Corner
- for (x1=0;x1<9;x1=x1+1)
- {
- wall_side.Set_Texture_Position(x1+11, 0.111f * x1, 1.0f, (1 + x1) * 0.111f, 1.0f, (1 + x1) * 0.111f, 0.0f, 0.111f * x1, 0.0f);
- wall_side.Set_Position(x1+11, wall_pts[13 + x1].x, wall_pts[13 + x1].y, values.wall_height, wall_pts[14 + x1].x,
- wall_pts[14 + x1].y, values.wall_height, wall_pts[14 + x1].x, wall_pts[14 + x1].y, 0.0f, wall_pts[13 + x1].x,
- wall_pts[13 + x1].y, 0.0f);
- }
-
- // Left Wall
- wall_side.Set_Position(20, wall_pts[22].x, wall_pts[22].y, values.wall_height, wall_pts[23].x, wall_pts[23].y,
- values.wall_height, wall_pts[23].x, wall_pts[23].y, 0.0f, wall_pts[22].x, wall_pts[22].y, 0.0f);
-
- wall_net.Set_Position(1, wall_pts[23].x, wall_pts[23].y, values.wall_height, wall_pts[24].x, wall_pts[24].y,
- values.wall_height, wall_pts[24].x, wall_pts[24].y, 0.0f, wall_pts[23].x, wall_pts[23].y, 0.0f);
-
- wall_side.Set_Position(21, wall_pts[24].x, wall_pts[24].y, values.wall_height, wall_pts[25].x, wall_pts[25].y,
- values.wall_height, wall_pts[25].x, wall_pts[25].y, 0.0f, wall_pts[24].x, wall_pts[24].y, 0.0f);
-
- // Top Left Corner
- for (x1=0;x1<9;x1=x1+1)
- {
- wall_side.Set_Texture_Position(x1+22, 0.111f * x1, 1.0f, (1 + x1) * 0.111f, 1.0f, (1 + x1) * 0.111f, 0.0f, 0.111f * x1, 0.0f);
- wall_side.Set_Position(x1+22, wall_pts[25 + x1].x, wall_pts[25 + x1].y, values.wall_height, wall_pts[26 + x1].x,
- wall_pts[26 + x1].y, values.wall_height, wall_pts[26 + x1].x, wall_pts[26 + x1].y, 0.0f, wall_pts[25 + x1].x,
- wall_pts[25 + x1].y, 0.0f);
- }
-
- // Top Wall
- wall_side.Set_Position(31, wall_pts[34].x, wall_pts[34].y, values.wall_height, wall_pts[35].x, wall_pts[35].y,
- values.wall_height, wall_pts[35].x, wall_pts[35].y, 0.0f, wall_pts[34].x, wall_pts[34].y, 0.0f);
-
- wall_net.Set_Position(2, wall_pts[35].x, wall_pts[35].y, values.wall_height, wall_pts[36].x, wall_pts[36].y,
- values.wall_height, wall_pts[36].x, wall_pts[36].y, 0.0f, wall_pts[35].x, wall_pts[35].y, 0.0f);
-
- wall_side.Set_Position(32, wall_pts[36].x, wall_pts[36].y, values.wall_height, wall_pts[37].x, wall_pts[37].y,
- values.wall_height, wall_pts[37].x, wall_pts[37].y, 0.0f, wall_pts[36].x, wall_pts[36].y, 0.0f);
-
- // Top Right Corner
- for (x1=0;x1<9;x1=x1+1)
- {
- wall_side.Set_Texture_Position(x1+33, 0.111f * x1, 1.0f, (1 + x1) * 0.111f, 1.0f, (1 + x1) * 0.111f, 0.0f, 0.111f * x1, 0.0f);
- wall_side.Set_Position(x1+33, wall_pts[37 + x1].x, wall_pts[37 + x1].y, values.wall_height, wall_pts[38 + x1].x,
- wall_pts[38 + x1].y, values.wall_height, wall_pts[38 + x1].x, wall_pts[38 + x1].y, 0.0f, wall_pts[37 + x1].x,
- wall_pts[37 + x1].y, 0.0f);
- }
-
- // Right Wall
- wall_side.Set_Position(42, wall_pts[46].x, wall_pts[46].y, values.wall_height, wall_pts[47].x, wall_pts[47].y,
- values.wall_height, wall_pts[47].x, wall_pts[47].y, 0.0f, wall_pts[46].x, wall_pts[46].y, 0.0f);
-
- wall_net.Set_Position(3, wall_pts[47].x, wall_pts[47].y, values.wall_height, wall_pts[48].x, wall_pts[48].y,
- values.wall_height, wall_pts[48].x, wall_pts[48].y, 0.0f, wall_pts[47].x, wall_pts[47].y, 0.0f);
-
- wall_side.Set_Position(43, wall_pts[48].x, wall_pts[48].y, values.wall_height, wall_pts[49].x, wall_pts[49].y,
- values.wall_height, wall_pts[49].x, wall_pts[49].y, 0.0f, wall_pts[48].x, wall_pts[48].y, 0.0f);
- }
-
- /***************************************************************************/
-
- void Initialize_Wall_Points(float radius, float length_top, float length_sides)
-
- {
- float interval = 1.0f;
- float2 temp;
- int x1;
-
- length_top = length_top - radius - radius;
- length_sides = length_sides - radius - radius;
- radius = radius;
-
- wall_pts[1].x = wall_pts[49].x = 150.0f;
- wall_pts[1].y = wall_pts[49].y = -50.0f;
-
- for (x1=2;x1<10;x1=x1+1)
- {
- interval = (float)(x1 - 1);
-
- wall_pts[x1].x = 100.0f + (Cos_F(interval * 10.0f) * 50.0f);
- wall_pts[x1].y = -100.0f - (Sin_F(interval * 10.0f) * 50.0f);
- }
-
- wall_pts[10].x = 50.0f;
- wall_pts[10].y = -150.0f;
- wall_pts[11].x = 50.0f;
- wall_pts[11].y = -190.0f;
- wall_pts[12].x = -50.0f;
- wall_pts[12].y = -190.0f;
- wall_pts[13].x = -50.0f;
- wall_pts[13].y = -150.0f;
-
- for (x1=14;x1<22;x1=x1+1)
- {
- interval = (float)(x1 - 13);
-
- wall_pts[x1].x = -100.0f - (Cos_F(interval * 10.0f) * 50.0f);
- wall_pts[x1].y = -100.0f - (Sin_F(interval * 10.0f) * 50.0f);
- }
-
- // Transfer 14 and 21
- temp.x = wall_pts[14].x; temp.y = wall_pts[14].y;
- wall_pts[14].x = wall_pts[21].x; wall_pts[14].y = wall_pts[21].y;
- wall_pts[21].x = temp.x; wall_pts[21].y = temp.y;
-
- // Transfer 15 and 20
- temp.x = wall_pts[15].x; temp.y = wall_pts[15].y;
- wall_pts[15].x = wall_pts[20].x; wall_pts[15].y = wall_pts[20].y;
- wall_pts[20].x = temp.x; wall_pts[20].y = temp.y;
-
- // Transfer 16 and 19
- temp.x = wall_pts[16].x; temp.y = wall_pts[16].y;
- wall_pts[16].x = wall_pts[19].x; wall_pts[16].y = wall_pts[19].y;
- wall_pts[19].x = temp.x; wall_pts[19].y = temp.y;
-
- // Transfer 17 and 18
- temp.x = wall_pts[17].x; temp.y = wall_pts[17].y;
- wall_pts[17].x = wall_pts[18].x; wall_pts[17].y = wall_pts[18].y;
- wall_pts[18].x = temp.x; wall_pts[18].y = temp.y;
-
- wall_pts[22].x = -150.0f; wall_pts[22].y = -50.0f;
- wall_pts[23].x = -190.0f; wall_pts[23].y = -50.0f;
- wall_pts[24].x = -190.0f; wall_pts[24].y = 50.0f;
- wall_pts[25].x = -150.0f; wall_pts[25].y = 50.0f;
-
- for (x1=26;x1<34;x1=x1+1)
- {
- interval = (float)(x1 - 25);
-
- wall_pts[x1].x = -100.0f - (Cos_F(interval * 10.0f) * 50.0f);
- wall_pts[x1].y = 100.0f + (Sin_F(interval * 10.0f) * 50.0f);
- }
-
- wall_pts[34].x = -50.0f; wall_pts[34].y = 150.0f;
- wall_pts[35].x = -50.0f; wall_pts[35].y = 190.0f;
- wall_pts[36].x = 50.0f; wall_pts[36].y = 190.0f;
- wall_pts[37].x = 50.0f; wall_pts[37].y = 150.0f;
-
- for (x1=38;x1<46;x1=x1+1)
- {
- interval = (float)(x1 - 37);
-
- wall_pts[x1].x = 100.0f + (Cos_F(interval * 10.0f) * 50.0f);
- wall_pts[x1].y = 100.0f + (Sin_F(interval * 10.0f) * 50.0f);
- }
-
- // Transfer 38 and 45
- temp.x = wall_pts[38].x; temp.y = wall_pts[38].y;
- wall_pts[38].x = wall_pts[45].x; wall_pts[38].y = wall_pts[45].y;
- wall_pts[45].x = temp.x; wall_pts[45].y = temp.y;
-
- // Transfer 39 and 44
- temp.x = wall_pts[39].x; temp.y = wall_pts[39].y;
- wall_pts[39].x = wall_pts[44].x; wall_pts[39].y = wall_pts[44].y;
- wall_pts[44].x = temp.x; wall_pts[44].y = temp.y;
-
- // Transfer 40 and 43
- temp.x = wall_pts[40].x; temp.y = wall_pts[40].y;
- wall_pts[40].x = wall_pts[43].x; wall_pts[40].y = wall_pts[43].y;
- wall_pts[43].x = temp.x; wall_pts[43].y = temp.y;
-
- // Transfer 41 and 42
- temp.x = wall_pts[41].x; temp.y = wall_pts[41].y;
- wall_pts[41].x = wall_pts[42].x; wall_pts[41].y = wall_pts[42].y;
- wall_pts[42].x = temp.x; wall_pts[42].y = temp.y;
-
- wall_pts[46].x = 150.0f; wall_pts[46].y = 50.0f;
- wall_pts[47].x = 190.0f; wall_pts[47].y = 50.0f;
- wall_pts[48].x = 190.0f; wall_pts[48].y = -50.0f;
-
- // Initialize z value
- for (x1=0;x1<50;x1=x1+1)
- wall_pts[x1].z = 1.0f;
- }
-
- /***************************************************************************/
-